package com.shr.code_interview;

public class Solution_55_1 {
	private boolean isBalance ;
    public boolean IsBalanced_Solution(TreeNode root) {
        isBalance = true;
        isBalalnce(root);
        return isBalance ;
    }
	private int isBalalnce(TreeNode root) {
		if(root == null)
			return 0;
		else{
			int leftDepth = isBalalnce(root.left);
			int rightDepth = isBalalnce(root.right);
			
			if(Math.abs(leftDepth - rightDepth) == 2){
				isBalance = false;
			}
			return leftDepth > rightDepth ? leftDepth + 1 : rightDepth + 1 ;
		}
	}
}
